<?php

namespace app\admin\controller;


use app\common\model\ShopMemberIdentity;
use buildView\Button;
use buildView\Detail;
use buildView\Filter;
use think\Controller;
use buildView\Form;
use buildView\Grid;

/**
 * 会员职业
 * Class MemberLevel
 * @package app\admin\controller
 */
class MemberIdentity extends Controller
{
    /**
     * 列表
     * @auth true
     * @menu true
     * @return string
     */
    public function index()
    {
        $grid = new Grid(new ShopMemberIdentity());
        $grid->identity_name('职业');
        $grid->create_at('创建时间');
        $grid->setFromOpen();
        // $grid->hideAddButton();
        $grid->hideDeletesButton();
        $grid->hideExportButton();
        $grid->filter(function(Filter $filter){
           $filter->like('identity_name','职业名称');
           $filter->dateBetween('create_at','注册时间');
        });
        $grid->actions(function($action,$data){
            $action->hideDel();
        });
        return $grid->view();
    }

    /**
     * 添加/编辑
     * @auth true
     * @menu true
     * @return string
     */
    public function form()
    {
        $form = new Form(new ShopMemberIdentity);
		$form->text('identity_name','职业名称')->required();
        $form->saved(function($post,$model){
            (new ShopMemberIdentity)->saveAll($post);
            return $post;
        });
        return $form->view();
    }

    /**
     * 详情
     * @auth true
     * @menu true
     * @return string
     */
    public function detail()
    {
        $detail = new Detail(new ShopMemberIdentity);
        $detail->setTitle('会员职业信息');
        $detail->layout('基本信息', 12, function ($detail) {
            $detail->identity_name('职业名称');
        });
        return $detail->view();
    }
    
}
